package com.decent.sms.dao;

import com.decent.common.cache.DecentRedisCache;
import com.decent.common.entity.sms.SmsConfig;
import com.decent.common.enums.sms.SmsConfigKeyEnum;
import org.apache.ibatis.annotations.CacheNamespace;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * 短信配置sql管理
 *
 * @author wangyx
 */
@CacheNamespace(implementation = DecentRedisCache.class, flushInterval = 24 * 60 * 60 * 1000)
@Mapper
public interface SmsConfigDao {
    /**
     * 批量查询短信配置
     *
     * @param keys 键集合
     * @return map
     */
    @Select("<script>" +
            " select config_key, config_value from sms_config where config_key in " +
            "<foreach collection = 'keys' item = 'key' separator = ',' open = '(' close = ')'> " +
            " #{key.name} " +
            "</foreach>" +
            "</script>")
    List<SmsConfig> batchQuery(@Param("keys") List<SmsConfigKeyEnum> keys);
}
